<html>
<head>
<script>
    if (window.testRunner)
        testRunner.dumpAsText();

    log = function(msg)
    {
        document.getElementById('console').appendChild(document.createTextNode(msg + "\n"));
    }

    shouldThrow = function(_a)
    {
        try {
            eval(_a);
            log("FAIL: " + _a + " did not throw");
        } catch(ex) {
            log("PASS: " + _a + " throws: " + ex);
        }
    }

    shouldNotThrow = function(_a)
    {
        try {
            eval(_a);
            log("PASS: " + _a + " did not throw");
        } catch(ex) {
            log("FAIL: " + _a + " throws: " + ex);
        }
    }

    onload = function()
    {
        shouldThrow("document.querySelector('bbb|pre')");
        shouldThrow("document.querySelectorAll('bbb|pre')");
        shouldThrow("document.body.webkitMatchesSelector('bbb|pre')");
        shouldNotThrow("document.querySelector('*|pre')");
        shouldNotThrow("document.querySelectorAll('*|pre')");
        shouldNotThrow("document.body.webkitMatchesSelector('*|pre')");
        shouldNotThrow("document.querySelector('|pre')");
        shouldNotThrow("document.querySelectorAll('|pre')");
        shouldNotThrow("document.body.webkitMatchesSelector('|pre')");

        shouldThrow("document.querySelector('div bbb|pre')");
        shouldThrow("document.querySelectorAll('div bbb|pre')");
        shouldThrow("document.body.webkitMatchesSelector('div bbb|pre')");
        shouldNotThrow("document.querySelector('div *|pre')");
        shouldNotThrow("document.querySelectorAll('div *|pre')");
        shouldNotThrow("document.body.webkitMatchesSelector('div *|pre')");
        shouldNotThrow("document.querySelector('div |pre')");
        shouldNotThrow("document.querySelectorAll('div |pre')");
        shouldNotThrow("document.body.webkitMatchesSelector('div |pre')");

        shouldThrow("document.querySelector('[bbb|name=value]')");
        shouldThrow("document.querySelectorAll('[bbb|name=value]')");
        shouldThrow("document.body.webkitMatchesSelector('[bbb|name=value]')");
        shouldNotThrow("document.querySelector('[*|name=value]')");
        shouldNotThrow("document.querySelectorAll('[*|name=value]')");
        shouldNotThrow("document.body.webkitMatchesSelector('[*|name=value]')");
        shouldNotThrow("document.querySelector('[|name=value]')");
        shouldNotThrow("document.querySelectorAll('[|name=value]')");
        shouldNotThrow("document.body.webkitMatchesSelector('[|name=value]')");

        shouldThrow("document.querySelector(':-webkit-any(bbb|pre)')");

        shouldThrow("document.querySelector('div [bbb|name=value]')");
        shouldThrow("document.querySelectorAll('div [bbb|name=value]')");
        shouldThrow("document.body.webkitMatchesSelector('div [bbb|name=value]')");
        shouldNotThrow("document.querySelector('div [*|name=value]')");
        shouldNotThrow("document.querySelectorAll('div [*|name=value]')");
        shouldNotThrow("document.body.webkitMatchesSelector('div [*|name=value]')");
        shouldNotThrow("document.querySelector('div [|name=value]')");
        shouldNotThrow("document.querySelectorAll('div [|name=value]')");
        shouldNotThrow("document.body.webkitMatchesSelector('div [|name=value]')");
    }
</script>
</head>
<body>
    <p>This tests that we throw a NAMESPACE_ERR when parsing a selector string for querySelector and querySelectorAll
        that contains a namespace.</p>
    <pre id="console" name="value"></pre>
</body>
</html>
